package com.eorchis.module.department.manager.impl;

import com.eorchis.core.basedao.condition.BaseTreeCondition;
import com.eorchis.core.servicetemplate.treetemplate.jsonbean.jsonnodeparameters.UpdateOrderParameter;
import com.eorchis.module.department.domain.Department;
import com.eorchis.module.department.domain.DepartmentTreeCondition;
import com.eorchis.module.department.domain.jsonbean.DepartmentTreeJsonBean;
import com.eorchis.module.department.dao.IDepartmentTreeDao;
import com.eorchis.module.department.manager.IDepartmentTreeManager;
import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Service;

@Service("com.eorchis.module.department.manager.impl.DepartmentTreeManagerImpl")
public class DepartmentTreeManagerImpl
  implements IDepartmentTreeManager
{

  @Autowired
  @Qualifier("com.eorchis.module.department.dao.impl.DepartmentTreeDaoImpl")
  private IDepartmentTreeDao departmentTreeSyncDao;

  public boolean isLeapNode(DepartmentTreeCondition condition)
    throws Exception
  {
    return this.departmentTreeSyncDao.isLeapNode(condition);
  }

  public void updateTreeOrderNum(BaseTreeCondition condition) throws Exception
  {
    DepartmentTreeCondition departmentTreeCondition = (DepartmentTreeCondition)condition;
    List<UpdateOrderParameter> updateOrderParameter = departmentTreeCondition.getUpdateOrderParameter();
    for (UpdateOrderParameter uop : updateOrderParameter)
      this.departmentTreeSyncDao.updateTreeOrderNum(uop);
  }

  public void updateTreeParentID(BaseTreeCondition condition)
    throws Exception
  {
    DepartmentTreeCondition departmentTreeCondition = (DepartmentTreeCondition)condition;
    this.departmentTreeSyncDao.updateTreeParentID(departmentTreeCondition);
  }

  public List<Department> listDepartmentTree(DepartmentTreeCondition condition) throws Exception
  {
    return this.departmentTreeSyncDao.listDepartmentTree(condition);
  }

  public List<Department> listUnSeclectDepartmentTree(DepartmentTreeCondition condition) throws Exception
  {
    return this.departmentTreeSyncDao.listUnSeclectDepartmentTree(condition);
  }
  
  public List<DepartmentTreeJsonBean> listDepartmentCheckedTree(DepartmentTreeCondition condition) throws Exception
  {
    return this.departmentTreeSyncDao.listDepartmentCheckedTree(condition);
  }

  public Department getDepartment(DepartmentTreeCondition condition) throws Exception
  {
    return this.departmentTreeSyncDao.getDepartment(condition);
  }

  public List<Department> listDepartmentProjectTree(DepartmentTreeCondition condition) throws Exception
  {
    return this.departmentTreeSyncDao.listDepartmentProjectTree(condition);
  }
}